﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using YT.Controls; 
using YT.DB ;
using YT.Commons; 

namespace YT.XH.MF
{
    public partial class frmmCaseHistory : Form
    {
        private DBAccess mdbcon = new DBAccess(false, false);
        private string mstrSickRecID = string.Empty;
        private TitleType mTitleType = new TitleType();
        public frmmCaseHistory()
        {
            InitializeComponent();
        }

        public frmmCaseHistory(string strSickRecID, TitleType titleType  )
        {
            InitializeComponent();
            mstrSickRecID = strSickRecID;
            mTitleType = titleType; 
        }

        private void frmmCaseHistory_Load(object sender, EventArgs e)
        {
            this.Text = "历史治疗方案";
            FillData();
        }

        private void FillData()
        {
            if (mTitleType != TitleType.SuddenDeafness)
                this.dgDtl.Columns[colDrug.Index].Visible = false;
            string strSQL = string.Empty;

            if (mTitleType == TitleType.NOSE || mTitleType == TitleType.IgE)
            {
                this.dgDtl.Columns[colDesc.Index].Visible = false;
                this.dgDtl.Columns[colCaseType.Index].Visible = false;
                this.dgDtl.Columns[colName.Index].Width = 200;
                strSQL = "select A.TreatCaseName, A.Thrombolysis, '' as Description,Period,A.BeginDate,A.CaseType from mTreatHistory A where SickRecID='" + mstrSickRecID + "' order by A.Recid";
            }
            else
            {
                if (mTitleType != TitleType.MeniereDisease) this.dgDtl.Columns[colCaseType.Index].Visible = false;
                strSQL = " select A.TreatCaseName, A.Thrombolysis, B.Description,Period,A.BeginDate,A.CaseType from mTreatHistory A " +
                                " inner join mTherapeuticMethod B on A.TreatCaseName= B.Name  where SickRecID='" + mstrSickRecID + "' and B.Type='" + mTitleType + "' order by A.Recid ";
            }
            DataTable dtTable = mdbcon.GetDataTable(strSQL);
            foreach (DataRow drRow in dtTable.Rows)
            {
                this.dgDtl.Rows.Add();      
                this.dgDtl.Rows[this.dgDtl.Rows.Count -1].Cells [colName.Index ].Value =CvtFunc.ToString ( drRow["TreatCaseName"]);
                this.dgDtl.Rows[this.dgDtl.Rows.Count - 1].Cells[colDesc.Index].Value = CvtFunc.ToString(drRow["Description"]);                
                this.dgDtl.Rows[this.dgDtl.Rows.Count - 1].Cells[colDrug.Index].Value = CvtFunc.ToString(drRow["Thrombolysis"]);
                this.dgDtl.Rows[this.dgDtl.Rows.Count - 1].Cells[ColBeginDate.Index].Value = BaseFunctions.FormatDate(CvtFunc.ToString ( drRow["BeginDate"]), DateFormatOption.DateFmtYMD);
                this.dgDtl.Rows[this.dgDtl.Rows.Count - 1].Cells[colCaseType.Index].Value = CvtFunc.ToString(drRow["CaseType"]);     
            }
            
        }

    }
}
